<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>两面翻转小案例</title>
  <style>
    body {
      /* 透视 */
      perspective: 600px;
    }

    .box {
      position: relative;
      width: 300px;
      height: 300px;
      margin: 100px auto;

      transition: all 1s;


      /* 让背面的盒子保留立体空间 给父级添加 */
      transform-style: preserve-3d;
    }

    /* 前面的盒子 */
    .before,
    .after {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: pink;
      border-radius: 50%;
      font-size: 30px;
      line-height: 300px;
      text-align: center;
      color: #fff;
    }

    .after {
      background-color: purple;
      /* 1. 先将后面的盒子旋转180度 背靠背展示 */
      transform: rotateY(180deg);
    }

    .before {
      background-color: pink;
    }

    .box:hover {
      transform: rotateY(180deg);
    }
  </style>
</head>

<body>

  <div class="box">
    <div class="before">黑马程序员</div>
    <div class="after">pink老师等你</div>
  </div>

</body>

</html>